-- 首先我们需要在 lua/basic/config.lua 中定义好需要缓存的路径：

-- 指定 undotree 缓存存放路径
-- vim.g.undotree_dir = "~/.cache/nvim/undodir"

-- https://github.com/mbbill/undotree

vim.cmd(
    [[
if has("persistent_undo")
    " 在 config.lua 中定义好了 undotree_dir 全局变量
    let target_path = expand(undotree_dir)
    if !isdirectory(target_path)
        call mkdir(target_path, "p", 0700)
    endif
    let &undodir = target_path
    set undofile
]]
)

-- 按键绑定，查看 undotree
vim.keybinds.gmap("n", "<leader>3", ":UndotreeToggle<CR>", vim.keybinds.opts)